import { publicInterface as request } from '@/api/request';
// 文件
/**
 * @description 上传文件(单个)
 * @method Post
 */
export function uploadFiles<R, T>(FormData: any) {
  return request.Post<R, T>('/file/upload', FormData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}

/**
 * @description 文件是否存在
 * @method Get
 */
export function isFiles<R, T>({ namespace, keys }: { namespace: string, keys: any }) {
  return request.Get<R, T>(`/file/exist?namespace=${namespace}&keys=${keys}`, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    // params: { namespace, keys },
  });
}

/**
 * @description 文件签名连接
 * @method Get
 */
export function getFilesUrl<R, T>(key: string) {
  return request.Get<R, T>('/file/url', {
    params: { key },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description 删除文件
 * @method Delete
 */
export function deleteFiles<R, T>({ namespace, keys }: { namespace: any, keys: any }) {
  return request.Delete<R, T>(`/file/delete?namespace=${namespace}&keys=${keys}`, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}
